package hospital;

import movement.Location;

/**
 * A class for creating Hospitals
 */
public class Hospital {
	
	/**
	 * Variable registering this hospital his name
	 */
	private String name;
	
	/**
	 * Variable registering this hospital his location
	 */
	private final Location location;
	
	/** 
	 * Initialize this new Hospital with a given name and location
	 * 
	 * @param	name
	 * 			The name for this hospital
	 * 
	 * @param 	location
	 * 			The location for this hospital
	 * 
	 * @post 	The name of this new hospital is the same as the given name.
	 * 
	 * @post 	The location of this new hospital is the same as the given location.
	 * 
	 * @throws 	IllegalArgumentException, if the given location is invalid (null)
	 * 
	 * @throws 	IllegalArgumentException, if the given name is invalid (null)
	 * 
	 * */
	public Hospital(String name, Location location){
		setName(name);
		if(canHaveAsLocation(location))
			this.location=location;
		else 
			throw new IllegalArgumentException(
			"A Hospital can't be created without a valid location");
	}

	/**
	 * Method for checking a Location can be assigned to this Hospital
	 * 
	 * @param 	Location
	 *          The location you want to check for validity
	 * 
	 * @return	Returns true if valid (not null), false if not
	 */
	public boolean canHaveAsLocation(Location location) {
		return (location != null);
	}

	/**
	 * Method for checking the name can be assigned to this Hospital
	 * 
	 * @param 	name
	 *         	The name you want to check for validity
	 * 
	 * @return 	Returns true if valid (not null), false if not
	 */
	public boolean canHaveAsName(String name) {
		return (name != null);
	}

	
	/**
	 * Getter for getting the location of this hospital
	 * 
	 * @return 	Returns the location of this hospital
	 */
	public Location getLocation() {
		return location;
	}
	
	/**
	 * Getter for getting the name of this hospital
	 * 
	 * @return Returns the name of this Hospital
	 */
	public String getName() {
		return name;
	}
	
	/**
	 * Method for setting the name of this hospital
	 * 
	 * @param	name
	 *          The name that needs to be set to name of it's hospital
	 * 
	 * @post 	The name of this hospital is changed to the given name
	 * 
	 * @throws 	IllegalArgumentException, when the name is null
	 */
	private void setName(String name) {
		if(canHaveAsName(name))
			this.name = name;
		else 
			throw new IllegalArgumentException("The name of an hospital cannot be null");
	}
}
